package OEScode;

import java.util.ArrayList;
import java.util.List;

public class Group extends Component{

    private String name;

    private List<Component> group;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Group(String name) {
        this.name = name;
        this.group = new ArrayList<>();
    }

    public void addChild(Component c){
        if (c != null && !group.contains(c)) {
            group.add(c);
        }
    }
    public void removeChild(Component c){
        group.remove(c);
    }

    @Override
    public void notify(String message) {
        System.out.println("考生组<"+name+">接到通知: "+message+"，正在通知下属人员...");
        for(Component c:group){
            c.notify(message);
        }
    }
}
